﻿using System;
using Xtensive.Orm;

namespace SalesPoint.Model
{
  [HierarchyRoot]
  public class Order : Entity
  {
    [Field, FieldMapping("OrderId"), Key]
    public int Id { get; private set; }

    [Field]
    public TimeSpan? ProcessingTime { get; set; }

    [Field]
    public Shipper ShipVia { get; set; }

    [Field]
    public Employee Employee { get; set; }

    [Field]
    public Customer Customer { get; set; }

    [Field(Indexed = true)]
    public DateTime? OrderDate { get; set; }

    [Field]
    public DateTime? RequiredDate { get; set; }

    [Field]
    public DateTime? ShippedDate { get; set; }

    [Field(Indexed = true)]
    public decimal? Freight { get; set; }

    [Field(Length = 60, Indexed = true)]
    public string ShipName { get; set; }

    [Field]
    public Address ShippingAddress { get; set; }

    [Field, Association(PairTo = "Order")]
    public EntitySet<OrderDetails> OrderDetails { get; private set; }

    public Order(Session session)
      : base(session)
    {
    }
  }
}